﻿<?xml version="1.0" encoding="utf-8"?><Articles><Article><ArticlesID>556</ArticlesID><Title>Lấy ng&amp;#224;y đầu ti&amp;#234;n trong tuần d&amp;#249;ng .NET</Title><Body>&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: csharp;&amp;quot;&amp;gt;
using System;
using System.Globalization;

namespace FirstDateOfWeekExample
{
    public static class FirstDateOfWeekUtility
    {
        public static DateTime GetFirstDateOfWeek(DateTime dayInWeek)
        {
            CultureInfo defaultCultureInfo = CultureInfo.CurrentCulture;
            return GetFirstDateOfWeek(dayInWeek, defaultCultureInfo);
        }

        public static DateTime GetFirstDateOfWeek(DateTime dayInWeek, CultureInfo cultureInfo)
        {
            DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;
            DateTime firstDateInWeek = dayInWeek.Date;
            while (firstDateInWeek.DayOfWeek != firstDay)
                firstDateInWeek = firstDateInWeek.AddDays(-1);
            return firstDateInWeek;
        }
    }
}&amp;lt;/pre&amp;gt;
&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: vb;&amp;quot;&amp;gt;
        Dim dt As Date = Date.Now
        Do While dt.DayOfWeek &amp;amp;lt;&amp;amp;gt; DayOfWeek.Sunday
            dt = dt.AddDays(1)
        Loop
        Response.Write(dt.ToString)&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;http://dev.meotom.net/2009/10/27/Lay-ngay-dau-tien-trong-tuan-dung-SQL-Server-22A.htm&amp;quot;&amp;gt;Lấy ng&amp;amp;agrave;y đầu ti&amp;amp;ecirc;n trong tuần d&amp;amp;ugrave;ng SQL&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;</Body><CommentEnabled>True</CommentEnabled><ViewCount>0</ViewCount><ReleaseDate>10/27/2009 10:39:31 PM</ReleaseDate><TotalComment>0</TotalComment><IsMedia>False</IsMedia><IsPicture>False</IsPicture><IsVote>True</IsVote><ArticlePassword /><PostVisible>0</PostVisible><ArticlePath>/2009/10/27/Lay-ngay-dau-tien-trong-tuan-dung--NET-22C</ArticlePath><Approved>True</Approved><ImagePath /><CategoryId>26</CategoryId><ArrayCatID>26|25</ArrayCatID></Article></Articles>